package com.github.livebase.bean;

import androidx.annotation.Nullable;

import com.github.livebase.util.base.ObjectsUtil;

import java.util.Map;
import java.util.Set;

/**
 * @ClassName Attachable1.java
 * @description: 附加信息
 * @author: biao532
 * @create: 2023-11-23 11:20
 * @Version 1.0
 **/
public class Attachable {
    // 附加信息
    private Map<String, String> opt = ObjectsUtil.Empty.MAP;

    public void setOpt(Map<String, String> opt) {
        this.opt = opt;
    }

    public Map<String, String> getOpt() {
        return opt;
    }

    public String get(String key) {
        return opt.get(key);
    }
    public String getOrDefault(String key, String val) {
        if (!containsKey(key)) {
            return val;
        }
        String v = get(key);
        return v==null?val:v;
    }

    public int optSize() {
        return opt.size();
    }

    public boolean isEmptyOpt() {
        return opt.isEmpty();
    }

    public boolean containsKey(@Nullable Object o) {
        return opt.containsKey(o);
    }

    public boolean containsValue(@Nullable Object o) {
        return opt.containsValue(o);
    }

    public String put(String s, String s2) {
        return opt.put(s, s2);
    }

    public String remove(@Nullable Object o) {
        return opt.remove(o);
    }

    public Set<String> keySet() {
        return opt.keySet();
    }
}
